package suzf.top.usercenter.service.impl

import rx.Observable
import rx.functions.Func1
import suzf.top.base.data.protocol.BaseResp
import suzf.top.base.ext.convert
import suzf.top.base.ext.convertBoolean
import suzf.top.base.rx.BaseException
import suzf.top.base.rx.BaseFuncBoolean
import suzf.top.usercenter.data.protocol.UserInfo
import suzf.top.usercenter.data.repository.UserRepository
import suzf.top.usercenter.service.UserService
import javax.inject.Inject

/**
 *
 *========================
 * Created with AndroidStudio
 * Author:Mr.Su
 * Date:2019-09-08
 * Time:10:22
 * ========================
 */
class UserServiceImpl @Inject constructor() : UserService {

    @Inject
    lateinit var repository: UserRepository

    /**
     * 注册
     */
    override fun register(mobile: String, pwd: String, verifyCode: String): Observable<Boolean> {

        return repository.register(mobile,pwd,verifyCode)
                .convertBoolean()
    }

    /**
     * 登录
     */
    override fun login(mobile: String, pwd: String, pushId: String): Observable<UserInfo> {
        return repository.login(mobile,pwd,pushId)
                .convert()
    }

    /**
     * 忘记密码
     */
    override fun forgetPwd(mobile: String, verifyCode: String): Observable<Boolean> {
        return repository.forgetPwd(mobile,verifyCode)
                .convertBoolean()
    }

    /**
     * 重置密码
     */
    override fun resetPwd(mobile: String, pwd: String): Observable<Boolean> {
        return repository.resetPwd(mobile,pwd)
                .convertBoolean()
    }

    /**
     * 修改用户资料
     */
    override fun editUser(userIcon: String, userName: String, userGender: String, userSign: String): Observable<UserInfo> {
        return repository.editUser(userIcon,userName,userGender,userSign)
                .convert()
    }
}